<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Rep\OrderChildRep;
use Illuminate\Http\Request;

class OrderChild extends Controller
{
    //生产订单管理
    protected $rep;

    public function __construct(Request $request)
    {
        $this->rep = new OrderChildRep();
    }

    /**
     * 获取订单列表
     * @param Request $request
     */
    public function getOrderChildList(Request $request){
        $params = $request->all();
        $data = $this->rep->getOrderChildListRep($params);
        return re(0,$data,'success');
    }

    /**指派订单**/
    public function assignOrderChild(Request $request){
        $params = $request->only(['allocate_num','child_order_id','user_id','employee_user_id']);
        $data = $this->rep->assignOrderChildRep($params);
        return re($data['code'],$data['data'],$data['msg']);
    }

    /**外包订单**/
    public function epibolyOrderChild(Request $request){
        $params = $request->all();
        $data = $this->rep->epibolyOrderChildRep($params);
        return re(0,$data,'success');
    }

    /**根据订单ID获取子订单列表**/
    public function getOrderChildListByOrderId(Request $request){
        $params = $request->all();
        $data = $this->rep->getOrderChildListByOrderIdRep($params);
        return re(0,$data,'success');
    }

    /**设置子订单状态**/
    public function setOrderChildStatus(Request $request){
        $params = $request->all();
        $data = $this->rep->setOrderChildStatusRep($params);
        return re($data['code'],$data['data'],$data['msg']);
    }

}
